<?php
/**
 * This file is form http://findcat.cn
 *
 * @link     https://findcat.cn
 * @email    1476982312@qq.com
 */
namespace Database\Seeder;

use Encore\Admin\Auth\Database\Menu;

/**
 * 生成权限的seeder基础方法.
 *
 * Trait MenuSeederMaker
 */
trait MenuSeederMaker
{
    /**
     * @param      $uri
     * @param      $parentId
     * @param      $order
     * @param      $title
     * @param      $icon
     * @param null $subTitle
     *
     * @return mixed
     */
    protected function createMenu($uri, $parentId, $order, $title, $icon)
    {
        return Menu::query()->updateOrCreate(
            [
                'uri' => $uri,
            ],
            [
                'parent_id' => $parentId,
                'order'     => $order,
                'title'     => $title,
                'icon'      => $icon,
            ]
        );
    }
}
